package com.cskaoyan.wx.controller;

import com.cskaoyan.bean.Brand;
import com.cskaoyan.service.BrandService;
import com.cskaoyan.vo.BaseRespVo;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/wx/brand")
public class WxBrandController {
    @Autowired
    BrandService brandService;



    @GetMapping("/list")
    public Object list(Integer page,Integer size){
        List<Brand> brandList = brandService.queryAllByPage(page, size);
        long total = PageInfo.of(brandList).getTotal();
        HashMap<Object, Object> data = new HashMap<>();
        data.put("totalPages",total);
        data.put("brandList",brandList);
        return BaseRespVo.ok(data);
    }

    @GetMapping("/detail")
    public Object detail(Integer id){
        Brand brand = brandService.selectById(id);
        HashMap<Object, Object> map = new HashMap<>();
        map.put("brand",brand);
        return BaseRespVo.ok(map);
    }


}
